package Thread;

class SingletonLazy {
    private static volatile SingletonLazy singletonLazy = null;
    private static final Object locker = new Object();

    public SingletonLazy getSingletonLazy() {

        if (singletonLazy == null) {
            synchronized (locker) {
                if (singletonLazy == null) {
                    singletonLazy = new SingletonLazy();
                }
            }
        }
        return singletonLazy;

    }

    // 构造方法设置为private，防止创造出多个实例
    private SingletonLazy() {
    }

}

public class ThreadDemo20 {
    public static void main(String[] args) {

    }
}
